package com.icreate.storm.methods.common;

import org.apache.commons.lang.time.FastDateFormat;

import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.util.Date;
import java.util.TimeZone;

/**
 * Created by hadoop on 17-5-3.
 */
public class DateMethod {
    //    private static SimpleDateFormat dateSDF = new SimpleDateFormat("yyyyMMdd");
//    private static FastDateFormat dateDF = FastDateFormat.getInstance("yyyyMMdd", TimeZone.getTimeZone("Asia/Shanghai"));
    private static FastDateFormat dateDF = FastDateFormat.getInstance("yyyyMMdd", TimeZone.getTimeZone("Asia/Shanghai"));
    //    private static SimpleDateFormat hourSDF = new SimpleDateFormat("HH");
    private static FastDateFormat hourDF = FastDateFormat.getInstance("HH", TimeZone.getTimeZone("Asia/Shanghai"));

    public static String getHour(String str) {
        long ts = Long.parseLong(str);
        return getHour(ts);
    }

    public static String getHour(long ts) {
//        Date dt = new Date(ts);
        return hourDF.format(ts + 12 * 60 * 60 * 1000);
    }

    public static String getDate(String str) {
        long ts = Long.parseLong(str);
        return getDate(ts);
    }

    public static String getDate(long ts) {
//        Date dt = new Date(ts);
        return dateDF.format(ts + 12 * 60 * 60 * 1000);
    }
}
